package org.lee.service;

import java.util.List;

import org.lee.bean.Person1;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.joinway.framework.data.jdbc.repository.TableRepository;

@Service
public class SecondaryService {

	@Autowired @Qualifier("agriRepository") protected TableRepository repository;
	
	public List<Person1> findAllPerson() throws Exception {
		return repository.findAll(Person1.class);
	}
	
	@Transactional(value="agriTransactionManager",rollbackFor=Throwable.class)
	public Person1 addPerson(String name) throws Exception {
		Person1 person = new Person1();
		person.setName(name);
		Person1 p = repository.save(person);
		
//		int i = 1 / 0;
		
		return p;
	}

}
